/*
 * 
 *  $Author: nfelipe$
 * 
 *  Copyright (c) 2011 by PROS Revenue Management.  All Rights Reserved.
 *  This software is the confidential and proprietary information of
 *  PROS Revenue Management ("Confidential Information").
 *  You shall not disclose such Confidential Information and shall use it
 *  only in accordance with the terms of the license agreement you entered
 *  into with PROS.
 * 
 */


import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.Frame;
import java.awt.RenderingHints;
import java.awt.image.*;
import java.awt.image.renderable.*;
import java.io.*;
import javax.imageio.*;

public class Main extends java.applet.Applet {
    Image i;
    int width = 200;
    int height = 200;
    public void init () {
        int[] pixels = new int [width*height];
        int c;
        double radianConversion = Math.PI / 180.0;
        for (int index=0,y=0;y<height;y++) {
            c = ((0xff) &
                (byte)(Math.abs (Math.sin((y+height)*radianConversion))* 255));
            for (int x=0;x<width;x++) {
                pixels[index++] = ((0xff<<24) | (c<<16) | (c<<8) | c);
            }
        }
        i = createImage (new MemoryImageSource (width, height, pixels, 0, width));
        setFont (new Font ("TimesRoman", Font.BOLD | Font.ITALIC, 32));
    }
    public void paint (Graphics g) {
        g.drawImage (i, 0, 0, this);
        g.drawString ("JavaWorld", 30, 80);
    }

    public static void main(String arg[]) throws IOException{
//        int width = 1000;
//        int height = 160;
//
//        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
////        int[] pixels = new int [width*height];
////        Image i = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource (width, height, pixels, 0, width));
////
//        Graphics2D g2 = image.createGraphics();
//        g2.setBackground(Color.BLUE);
////        g2.drawImage(i, 0, 0, new java.applet.Applet());
//        g2.setColor(Color.PINK);
//        g2.setFont(new Font ("TimesRoman", Font.BOLD | Font.ITALIC, 32));
//        g2.drawString("hola nena", 0, 0);
//
//        File outputfile = new File("imagewithtext.png");
//        ImageIO.write(image, "png", outputfile);

        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        Font[] allfonts = ge.getAllFonts();
        for (int i = 0; i < allfonts.length; i++){
            System.out.println(allfonts[i]);
        }
        System.out.println(allfonts.length);
//
//        Frame frame = new Frame("deleteme");
//        frame.setSize(200,200);
//        Applet app = new jwmen2();
//        frame.add(app);
//        frame.setVisible(true);
//        frame.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){
//          System.exit(0);
//          }
//          });
    }
}
